﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ImageHandler
{
	public class MatchResults
	{
		public MatchResults()
		{
			Results = new List<ImageMatch>();
		}

		public int MaxResults { get; set; }
		public List<ImageMatch> Results { get; set; }

		public void InsertImageMatch(ImageMatch insertMatchContext)
		{
			int insertIndex = 0;

			ImageMatch insertMatch = new ImageMatch(insertMatchContext);

			foreach (var imageMatch in Results)
			{				
				if (insertMatch.TotalPairMatches > imageMatch.TotalPairMatches)
				{
					break;
				}
				insertIndex++;
			}
			
			Results.Insert(insertIndex, insertMatch);

			while (Results.Count > MaxResults)
			{
				Results.RemoveAt(Results.Count-1);
			}
		}
	}
}
